const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('act_ru_task', {
    id: {
      type: DataTypes.STRING(64),
      allowNull: false,
      primaryKey: true,
      field: 'ID_'
    },
    rev: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'REV_'
    },
    executionId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'EXECUTION_ID_'
    },
    procInstId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'PROC_INST_ID_'
    },
    procDefId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_re_procdef',
        key: 'id_'
      },
      field: 'PROC_DEF_ID_'
    },
    taskDefId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      field: 'TASK_DEF_ID_'
    },
    scopeId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_ID_'
    },
    subScopeId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SUB_SCOPE_ID_'
    },
    scopeType: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_TYPE_'
    },
    scopeDefinitionId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_DEFINITION_ID_'
    },
    name: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'NAME_'
    },
    parentTaskId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      field: 'PARENT_TASK_ID_'
    },
    description: {
      type: DataTypes.STRING(4000),
      allowNull: true,
      field: 'DESCRIPTION_'
    },
    taskDefKey: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'TASK_DEF_KEY_'
    },
    owner: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'OWNER_'
    },
    assignee: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'ASSIGNEE_'
    },
    delegation: {
      type: DataTypes.STRING(64),
      allowNull: true,
      field: 'DELEGATION_'
    },
    priority: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'PRIORITY_'
    },
    createTime: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'CREATE_TIME_'
    },
    dueDate: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'DUE_DATE_'
    },
    category: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'CATEGORY_'
    },
    suspensionState: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'SUSPENSION_STATE_'
    },
    tenantId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: "",
      field: 'TENANT_ID_'
    },
    formKey: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'FORM_KEY_'
    },
    claimTime: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'CLAIM_TIME_'
    },
    isCountEnabled: {
      type: DataTypes.TINYINT,
      allowNull: true,
      field: 'IS_COUNT_ENABLED_'
    },
    varCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'VAR_COUNT_'
    },
    idLinkCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'ID_LINK_COUNT_'
    },
    subTaskCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'SUB_TASK_COUNT_'
    }
  }, {
    sequelize,
    tableName: 'act_ru_task',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "ID_" },
        ]
      },
      {
        name: "ACT_IDX_TASK_CREATE",
        using: "BTREE",
        fields: [
          { name: "CREATE_TIME_" },
        ]
      },
      {
        name: "ACT_IDX_TASK_SCOPE",
        using: "BTREE",
        fields: [
          { name: "SCOPE_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_IDX_TASK_SUB_SCOPE",
        using: "BTREE",
        fields: [
          { name: "SUB_SCOPE_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_IDX_TASK_SCOPE_DEF",
        using: "BTREE",
        fields: [
          { name: "SCOPE_DEFINITION_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_FK_TASK_EXE",
        using: "BTREE",
        fields: [
          { name: "EXECUTION_ID_" },
        ]
      },
      {
        name: "ACT_FK_TASK_PROCINST",
        using: "BTREE",
        fields: [
          { name: "PROC_INST_ID_" },
        ]
      },
      {
        name: "ACT_FK_TASK_PROCDEF",
        using: "BTREE",
        fields: [
          { name: "PROC_DEF_ID_" },
        ]
      },
    ]
  });
};
